<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
	</body>
	<script>
		const obj = {};
		obj['a'+'bc'] = 123;
		console.log(obj);
		
		let obj1 = {
			['he'+'llo'](){
				return 'hello';
			}
		}
		console.log(obj1.hello());
		console.log(obj1.hello.name);
		
		const obj2 = {
			get foo() {},
			set foo(x) {}
		};
		//此时直接打印obj2.foo.name是会报错的
		const descriptor = Object.getOwnPropertyDescriptor(obj2,'foo');
		console.log(descriptor.get.name);
		console.log(descriptor.set.name);
		
		//Object.is比较两个值是否相等，与===基本一致
		console.log(Object.is('1',1));
		console.log(Object.is('goo','goo'));
		const o1 = {};
		console.log(o1);
		const o2 = {};
		console.log(o2);
		console.log(Object.is(o1,o2));
		console.log(Object.is(-0,+0));
		console.log(Object.is(NaN,NaN));
		
		//Object.assign用于对象的合并,第一个参数是目标对象，后面的参数都是源对象
		//如果目标对象或者源对象中有同名的属性，后面的会覆盖前面的
		const target = {a:1};
		const source1 = {b:'a'};
		const source2 = {c : 3};
		console.log(Object.assign(target,source1,source2));
		const obj0 = {a:{b:1}};
		const obj01 = Object.assign({},obj0);
		console.log(obj01);
		obj01.a.b = 4;
		console.log(obj01);
		console.log(obj0);
		
		//Object.values()、Object.keys()、Object.entries()
		const oo = {foo:'1',baz:'2',baw:'3'};
		for(let key of Object.keys(oo)){
			console.log(key);
		}
		for(let value of Object.values(oo)){
			console.log(value);
		}
		for(let [key,value] of Object.entries(oo)){
			console.log(`${key} : ${value}`);
		}
		
		let symObj = {
			s:'s0'
		};
		let s = Symbol('s');
		console.log(typeof s);
		symObj[s] = 's1';
		let s1 = Symbol('s1');
		console.log(symObj);
		symObj[s1] = 's2';
		console.log(symObj);
		let func = Symbol('func');
		let a = {};
		 a[func] = () => {
			console.log('11');	
		}
		 console.log(a);
		 a.func();
		 
	</script>
</html>
